package com.water.devtool.ui;

import org.apache.commons.lang.StringUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ST;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;

public class CodePreviewComposite extends Composite {
	private StyledText styledText;

	/**
	 * Create the composite.
	 * 
	 * @param parent
	 * @param style
	 */
	public CodePreviewComposite(Composite parent, int style) {
		super(parent, style);
		setLayout(new FillLayout(SWT.HORIZONTAL));

		styledText = new StyledText(this, SWT.V_SCROLL);
		styledText.setKeyBinding('A' | SWT.CTRL, ST.SELECT_ALL);
	}

	@Override
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	}

	public void setContent(String string) {
		if (!StringUtils.isBlank(string)) {
			styledText.setText(string);
		}
	}

}
